package comet;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

public class CollegeTestBean implements CollegeTestBeanRemote {

	@PersistenceContext(name = "College")
	private EntityManager em; //L'Entity Manager

	public void addCollege(College var) {
		em.persist(var);
	}

	public College rechercherCollege(String var) {
		return em.find(College.class, var);
	}

	public void deleteCollege(String var) {
		College resReq = rechercherCollege(var);
		if (resReq != null) {
			em.remove(resReq);
		}
	}

	public List<College> listerTousLesCollege() {
		return em.createQuery("SELECT * FROM TableCollege  ").getResultList();
	}

	public College updateCollege(College var1, College var2) {
		College var = em.find(College.class, var1.getNom());
		if (var != null) {
			var.setNom(var2.getNom());

			var.setWebSite(var2.getWebSite());

		}

		return var;
	}

}
